/*LICENSE_BEGIN
 * ******************************************************************
 * Copyright 2006 by the Dainamite Robocup-Team at the
 * DAI-Labor, TU-Berlin (www.dai-labor.de)
 * 
 * Members of Dainamite are:
 * Holger Endert
 * Robert Wetzker
 * Thomas Karbe
 * Axel Heßler
 * Philippe Bütter
 * Felix Brossmann
 * 
 * Licensed under the GNU GPL (General Public License) Free Software 
 * License, Version 2. You may use this file only in compliance with 
 * the License. You may obtain a copy of the License at:
 * 
 * http://www.fsf.org/licensing/licenses/gpl.txt
 * ******************************************************************
LICENSE_END*/
package robocup.component.tactics;

import robocup.component.situations.PassSituation;

/**
 * The state for passing. Only triggered when the player has the ball.
 * 
 * @see PassSituation
 */
public class PassState extends AbstractState {

	/**
	 * State that determines if passing is good
	 * 
	 * @param parent -
	 *            the StateEvaluation (parent) object
	 */
	public PassState(StateEvaluation parent) {

		super(parent);
		this.state = STATES.PASS;
	}

	/**
	 * Player has to control the ball.
	 */
	@Override
	public boolean preCondition() {
		boolean simpleCheck = this.checkPlayMode() && this.checkMyBall();

		if (!simpleCheck)
			return false;
		
    boolean b = this.getProphet().getScoreBenefit() < 0.70
				&& this.getProphet().canPass();

		return b;
	}

	/**
	 * Dummy.
   * 
   * @see PassSituation
	 */
	@Override
	protected double successProbability() {

		return 1.0;
	}

	/**
	 * The success benefit depends on the situation that results from the pass.
   * 
   * @see PassSituation
	 */
	@Override
	protected double successBenefit() {

		double passBenefit = getProphet().getPassBenefit();
		return passBenefit;
	}

	@Override
	public void calculateMainAction() {
		mainAction = this.getProphet().getPassAction();
	}
}
